﻿using FluentNHibernate.Mapping;
using SOLInfo.GEN.Domain.Entities;
using SOLInfo.GEN.Domain.VO;
using System;


namespace SOLInfo.GEN.Repository.Mappings
{
    public class UsuarioMapping : ClassMap<Usuario>
    {
        public UsuarioMapping()
        {
            Id(x => x.Codigo);
            Map(x => x.Password).Not.Nullable();
            Map(x => x.Status);
            Map(x => x.UserName).Not.Nullable().Length(15);
            HasManyToMany<Grupo>(x => x.Grupos)
                .Cascade.SaveUpdate()
                .Table("Usuario_Grupo");
            HasMany<Noticia>(x => x.Noticias)
                .Cascade.SaveUpdate()
                .Inverse();

            Component<Manutencao>(x => x.Criacao, MappingBase.MapManutencao("Criacao"));
            Component<Manutencao>(x => x.UltimaAlteracao, MappingBase.MapManutencao("Alteracao"));
        }
    }
}
